package com.ken.checkviolationapp

import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.junit.After
import org.junit.Before
import org.junit.Test

import org.junit.Assert.*
import kotlin.random.Random

/**
 * @author by ken
 * Blog:
 * Date:2020/4/27
 * Description:
 */
class MainActivityTest {

    @Before
    fun setUp() {
    }

    @After
    fun tearDown() {
    }

    @Test
    fun test1() {
        runBlocking {
            val job = launch {
                for (i in 0..9) {
                    println("子协程执行第${i}次")
                    val sleeptime = (1000 * Math.random()).toLong()
                    println("随机生成的挂起时间${sleeptime}")
                    delay(sleeptime)
                }
                println("子协程结束")

                delay(10000L)
                println("主线程结束")

            }
        }
    }

    @Test
    fun test2() {


    }
}